This is an example of how to add a Print Button to an Operator Window. The steps are;
var currentBitmapToPrint = null; var printMarginPixel = 100; function PrintControl(control) { PrintControl2(control, true, true) } function PrintControl2(control, landscape, autoScale) { var printPreviewDialog1 = new System.Windows.Forms.PrintPreviewDialog(); currentBitmapToPrint = new System.Drawing.Bitmap(control.Width, control.Height); control.DrawToBitmap(currentBitmapToPrint, new System.Drawing.Rectangle(0, 0, control.Width, control.Height)); var pd = new System.Drawing.Printing.PrintDocument(); pd.DefaultPageSettings.Landscape = landscape; printPreviewDialog1.Document = pd; if (autoScale) pd.add_PrintPage(OnPrintPageAutoScale); else pd.add_PrintPage(OnPrintPage); printPreviewDialog1.ShowDialog(); } function OnPrintPage(sender, e) { e.Graphics.DrawImage(currentBitmapToPrint, 100, 100); } function OnPrintPageAutoScale(sender, e) { var newWidth = currentBitmapToPrint.Width * 100 / currentBitmapToPrint.HorizontalResolution; var newHeight = currentBitmapToPrint.Height * 100 / currentBitmapToPrint.VerticalResolution; var widthFactor = newWidth / e.MarginBounds.Width; var heightFactor = newHeight / e.MarginBounds.Height; if (widthFactor > 1 | heightFactor > 1) { if (widthFactor > heightFactor) { newWidth = newWidth / widthFactor; newHeight = newHeight / widthFactor; } else { newWidth = newWidth / heightFactor; newHeight = newHeight / heightFactor; } } e.Graphics.DrawImage(currentBitmapToPrint, printMarginPixel, printMarginPixel, newWidth, newHeight); }